#ifndef __BLENDCODECSTREAM_H__
#define __BLENDCODECSTREAM_H__

#include "AudioCodecStream.h"
#include "VideoCodecStream.h"

class CCodecManager;

/////////////////////////////////////////Class IDs////////////////////////////////////////////

//#define CLASS_ID_CBLENDCODECSTREAM 0x30000
#define CLASS_ID_CBLENDSTREAMENCODER 0x30100
#define CLASS_ID_CBLENDSTREAMDECODER 0x30200
#define CLASS_ID_CBLENDFILEENCODER 0x30101
#define CLASS_ID_CBLENDFILEDECODER 0x30201


/////////////////////////////////////////Raw Class////////////////////////////////////////////


/////////////////////////////////////////Proxy Classes////////////////////////////////////////////

class CBlendStreamEncoder:
	public CAudioCodecStream,public CVideoCodecStream
{
public:
	CBlendStreamEncoder(CAudioCodecStream* pS,CVideoCodecStream* pVS){pStream=pS;pVideoStream=pVS;};
	virtual ~CBlendStreamEncoder(){};
	virtual unsigned long GetClassID(){return CLASS_ID_CBLENDSTREAMENCODER;};
	static unsigned long CLASS_ID(){return CLASS_ID_CBLENDSTREAMENCODER;};

	virtual int PushData(float* plChnl, float* prChnl, int nSamples)
	{return pStream->PushData(plChnl,prChnl,nSamples);};
	CAudioCodecStream* getCodecStream(){return pStream;};
	CVideoCodecStream* getVideoCodecStream(){return pVideoStream;};
	virtual bool Play(){return pStream->Play();};
	virtual void Stop(){pStream->Stop();};
	virtual long GetStreamID(){return pStream->GetStreamID();};
	virtual int PushPacketToList(char* data,int size,int sample_rate=0,int bit_rate=0,int channels=0)
	{return pStream->PushPacketToList(data,size,sample_rate,bit_rate,channels);};
	friend class CCodecManager;
protected:
	CBlendStreamEncoder(){};
	CBlendStreamEncoder(CBlendStreamEncoder&){};
	CAudioCodecStream* pStream;
	CVideoCodecStream* pVideoStream;
};

class CBlendFileEncoder:
	public CBlendStreamEncoder
{
public:
	CBlendFileEncoder(CAudioCodecStream* pS,CVideoCodecStream* pVS){pStream=pS;pVideoStream=pVS;};
	virtual ~CBlendFileEncoder(){};
	virtual unsigned long GetClassID(){return CLASS_ID_CBLENDFILEENCODER;};
	static unsigned long CLASS_ID(){return CLASS_ID_CBLENDFILEENCODER;};

	virtual bool Load(char* path)
	{return pStream->Load(path,true);};
	virtual void Pause(){pStream->Pause();};
	virtual uint64_t GetPlayPosInSeconds(){return pStream->GetPlayPosInSeconds();};
	virtual uint64_t GetFileSizeInSeconds(){return pStream->GetFileSizeInSeconds();};
	friend class CCodecManager;
protected:
	CBlendFileEncoder(){};
	CBlendFileEncoder(CBlendFileEncoder&){};
};

class CBlendStreamDecoder:
	public CAudioCodecStream,public CVideoCodecStream
{
public:
	CBlendStreamDecoder(CAudioCodecStream* pS,CVideoCodecStream* pVS){pStream=pS;pVideoStream=pVS;};
	virtual ~CBlendStreamDecoder(){};
	virtual unsigned long GetClassID(){return CLASS_ID_CBLENDSTREAMDECODER;};
	static unsigned long CLASS_ID(){return CLASS_ID_CBLENDSTREAMDECODER;};

	virtual int PushData(float* plChnl, float* prChnl, int nSamples)
	{return pStream->PushData(plChnl,prChnl,nSamples);};
	CAudioCodecStream* getCodecStream(){return pStream;};
	CVideoCodecStream* getVideoCodecStream(){return pVideoStream;};
	virtual bool Play(){return pStream->Play();};
	virtual void Stop(){pStream->Stop();};
	virtual long GetStreamID(){return pStream->GetStreamID();};
	virtual int GetPacketFromList(char* data,int size,int sample_rate=0,int bit_rate=0,int channels=0)
	{return pStream->GetPacketFromList(data,size,sample_rate,bit_rate,channels);}
	friend class CCodecManager;
protected:
	CBlendStreamDecoder(){};
	CBlendStreamDecoder(CBlendStreamDecoder&){};
	CAudioCodecStream* pStream;
	CVideoCodecStream* pVideoStream;
};


class CBlendFileDecoder:
	public CBlendStreamDecoder
{
public:
	CBlendFileDecoder(CAudioCodecStream* pS,CVideoCodecStream* pVS){pStream=pS;pVideoStream=pVS;};
	virtual ~CBlendFileDecoder(){};
	virtual unsigned long GetClassID(){return CLASS_ID_CBLENDFILEDECODER;};
	static unsigned long CLASS_ID(){return CLASS_ID_CBLENDFILEDECODER;};

	virtual bool Load(char* path)
	{return pStream->Load(path,false);};
	virtual void Pause(){pStream->Pause();};
	virtual uint64_t Seek(uint64_t second){return pStream->Seek(second);};
	virtual uint64_t GetPlayPosInSeconds(){return pStream->GetPlayPosInSeconds();};
	virtual uint64_t GetFileSizeInSeconds(){return pStream->GetFileSizeInSeconds();};
	friend class CCodecManager;
protected:
	CBlendFileDecoder(){};
	CBlendFileDecoder(CBlendFileDecoder&){};
};

#endif